from meiduo import settings
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from apps.autho.constants import OPENID_TOKEN_EXPIRES_TIME


def secret(openid):
    secrecy = Serializer(settings.SECRET_KEY, OPENID_TOKEN_EXPIRES_TIME)
    data_dict = {
        'openid': openid
    }
    data_str = secrecy.dumps(data_dict).decode()
    return data_str


def secretOpen(data_str):
    secrecy = Serializer(settings.SECRET_KEY, OPENID_TOKEN_EXPIRES_TIME)
    data_dict = secrecy.loads(data_str)
    return data_dict


# print(secret('aaaaa'))
# print(secretOpen(secret('aaaaa')))